<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();
            $table->integer('uid')->index();
            $table->morphs('goods');
            $table->tinyInteger('pay_type')->default(0)->comment('默认0，1积分支付');
            $table->string('trade_no')->index();
            $table->string('out_trade_no')->default('')->index();
            $table->integer('price');
            $table->tinyInteger('status')->comment('0未支付，1支付中，2支付成功，3支付失败，4超时未支付，5已取消');
            $table->string('remark')->default('');
            $table->text('snapshot');
            $table->string('request_id');
            $table->dateTime('paid_at')->nullable()->comment('支付时间');
            $table->dateTime('canceled_at')->nullable()->comment('取消时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
